<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="MvcContrib.UI.Grid"%>
<%@ Import Namespace="etcetera.Mvc.UI.Toolbar"%>
<%@ Import Namespace="Samples.Models"%>
<%@ Import Namespace="etcetera.Mvc.UI.Grid"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Grid and Pager Toolbar Demo</h2>
    
    <h3>Grid with Ajax paging</h3>
    
    <%= Html.GridEx<Actor>("Actors")
            .Titled("Actors")
            .WithId("Act")
            .WithToolStripId("pgrA")
            .Columns(col =>
                         {
                             col.For(x => Html.ActionLink(x.Id.ToString(), "Actor", new { Id = x.Id })).DoNotEncode().Named("Id");
                             col.For(x => x.FirstName).Sortable(false);
                             col.For(x => x.LastName).Sortable(true);
                         })
            .ColWidth("30px", "200px", "200px")
    %>
    
    <%= Html.PagerToolStrip("Actors")            
            .AjaxUrl(Url.Action("Actors", "Grid"))
            .AddToolbar(new Toolbar().AddButton("Add new Actor", Url.Action("New", "Grid"), "tBtnA"))
            .AddToolbar(new Toolbar().AddPageSizeSelect(10, 20, 50, 100))
            .AddToolbar(new Toolbar().AddNavButton(NavButton.First)
                                     .AddNavButton(NavButton.Previous))
            .AddToolbar(new Toolbar().AddPageInput())
            .AddToolbar(new Toolbar().AddNavButton(NavButton.Next)
                                     .AddNavButton(NavButton.Last))
            .AddToolbar(new Toolbar().AddPageStatus())
            .AddToolbar(new Toolbar().AddRefreshButton("Refresh Actors"))
            .AddToolbar(new Toolbar().AddButton("Export all Actors to Excel", Url.Action("ActorsExcel"), "tBtnXls"))
            .WithId("pgrA")
            .WithGridId("Act")
            .Format("Showing {0} to {1} of {2} actors")
            .SinglePageFormat("Showing {0} of {2} actors")
            .KeepPageSize()
            .ColModel(col =>
                        {
                            col.For("id").Format("<a href=\"Grid/Actor/{1}\">{0}</a>", "id");
                            col.For("firstname");
                            col.For("lastname");
                        })
    %>
    
    <h3>Grid without Ajax paging (updates both grids, they share the same model)</h3>
    
    <%= Html.GridEx<Actor>("Actors")
            .Titled("Actors")
            .WithId("ActRegular")
            .Columns(col =>
                         {
                             col.For(x => Html.ActionLink(x.Id.ToString(), "Actor", new { Id = x.Id })).DoNotEncode().Named("Id");
                             col.For(x => x.FirstName).Sortable(false);
                             col.For(x => x.LastName).Sortable(true);
                         })
            .ColWidth("30px", "200px", "200px")
    %>
    
    <%= Html.PagerToolStrip("Actors")            
            .AddToolbar(new Toolbar().AddButton("Add new Actor", Url.Action("New", "Grid"), "tBtnA"))
            .AddToolbar(new Toolbar().AddPageSizeSelect(10, 20, 50, 100))
            .AddToolbar(new Toolbar().AddNavButton(NavButton.First)
                                     .AddNavButton(NavButton.Previous))
            .AddToolbar(new Toolbar().AddPageInput())
            .AddToolbar(new Toolbar().AddNavButton(NavButton.Next)
                                     .AddNavButton(NavButton.Last))
            .AddToolbar(new Toolbar().AddPageStatus())
            .AddToolbar(new Toolbar().AddRefreshButton("Refresh Actors"))
            .AddToolbar(new Toolbar().AddButton("Export all Actors to Excel", Url.Action("ActorsExcel"), "tBtnXls"))
                    .WithId("pgrActReg")
            .WithGridId("ActRegular")
            .Format("Showing {0} to {1} of {2} actors")
            .SinglePageFormat("Showing {0} of {2} actors")
            .KeepPageSize()
            .ColModel(col =>
                        {
                            col.For("id").Format("<a href=\"Grid/Actor/{1}\">{0}</a>", "id");
                            col.For("firstname");
                            col.For("lastname");
                        })
    %>

</asp:Content>
